package top.frsf.schedule;

import top.frsf.constants.ImageConstant;
import top.frsf.object.zombie.NormalZom;
import top.frsf.object.zombie.ZomObject;
import top.frsf.panel.GamePanel;
import top.frsf.starter.impl.ZomStarter;

import java.util.ArrayList;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;

/**
 * @author He Kuntao
 * @since 2025/8/4 17:05
 */
public class ZomTmeTask extends TimerTask {
    /**
     * 定时任务定时器
     */
    private static final Timer timer = new Timer();
    /**
     * 随机数生成器
     */
    private final Random random = new Random();

    @Override
    public void run() {
        ZomStarter zomStarter = GamePanel.starterContext.getStarter(ZomStarter.class);
        String imageUrl = String.format(ImageConstant.Zom.ZOM_MOVE, 0);
        zomStarter.getZomList().add(new NormalZom(imageUrl, 850, 90 + 95 * random.nextInt(5), 90, 120));
    }

    public static void start() {
        timer.schedule(new ZomTmeTask(), 15000, 15000);
    }
}
